//
//  UserDefaultsManager.m
//  NewPro
//
//  Created by 何荧红 on 2018/10/19.
//  Copyright © 2018 何荧红. All rights reserved.
//

#import "UserDefaultsManager.h"

@implementation UserDefaultsManager
+ (UserDefaultsManager *)sharedInstance{
    static UserDefaultsManager *myInstance = nil;
    static dispatch_once_t predicate;
    dispatch_once(&predicate, ^{
        myInstance = [[self alloc] init];
    });
    return myInstance;
}

- (BOOL)LoginSuccess{
    NSString *useid = @"";
    if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"id"] isKindOfClass:[NSString class]]) {
        useid = [[NSUserDefaults standardUserDefaults] objectForKey:@"id"];
    }else if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"id"] isKindOfClass:[NSNumber class]]) {
        useid = [[[NSUserDefaults standardUserDefaults] objectForKey:@"id"] stringValue];
    }
    if(useid){
        if(useid.length > 0){
            return YES;
        }else{
            return NO;
        }
    }else{
        return NO;
    }
}

- (void)iSNewVersionSuccess:(void(^)(NSDictionary *res))success Failure:(void(^)(NSError *error))failure{
    NSString *url = @"http://itunes.apple.com/cn/lookup?id=1441197795";
    [HttpTool getUrlWithString:url parameters:@{} success:^(id responseObject) {
        NSError *error = [HttpTool inspectError:responseObject];
        if (error == nil) {
            success(responseObject);
        }else{
            failure(error);
        }
    } failure:^(NSError *error) {
        failure(error);
    }];
}

@end
